from common.base import Base, By
from selenium.webdriver.support.ui import Select


class RegisterPage(Base):
    """
    注册页面
    """
    def input_username(self, username):
        # 输入用户名
        self.find_element((By.NAME, 'username')).send_keys(username)

    def input_email(self, email):
        # 输入邮箱
        self.find_element((By.NAME, 'email')).send_keys(email)

    def input_password(self, password):
        # 输入密码
        self.find_element((By.NAME, 'password')).send_keys(password)

    def input_confirm_password(self, confirm_password):
        # 再次输入密码
        self.find_element((By.NAME, 'confirm_password')).send_keys(confirm_password)

    def input_qq(self, extend_field2):
        # 输入QQ
        self.find_element((By.NAME, 'extend_field2')).send_keys(extend_field2)

    def input_phone(self, extend_field5):
        # 输入手机号
        self.find_element((By.NAME, 'extend_field5')).send_keys(extend_field5)

    def a_drop_down_box(self, index):
        # 下拉框, 创建select对象, 参数是要操作的select标签
        s1 = self.find_element((By.NAME, 'sel_question'))
        select = Select(s1)
        # 通过索引选取option
        select.select_by_index(index)

    def input_passwd_answer(self, passwd_answer):
        # 密保答案
        self.find_element((By.NAME, 'passwd_answer')).send_keys(passwd_answer)

    def input_submit(self):
        # 注册按键
        self.click((By.NAME, 'Submit'))

